﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Ex4_Calculation : System.Web.UI.Page
{
    //num1存储算式中第一个数字字符；num2存储算式中第二个数字字符串
    //total存储将输入的
    static string num1 = "0", num2 = "0", total = "", sign = "";

    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Count()
    {

    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        total += "1";//将数字字符串“1”与total原值连接后再存入total
        txtDisplay.Text = total;
    }

    protected void btnTwo_Click(object sender, EventArgs e)
    {
        total += "2";
        txtDisplay.Text = total;
    }

    protected void btnThree_Click(object sender, EventArgs e)
    {
        total += "3";
        txtDisplay.Text = total;
    }

    protected void btnAdd_Click(object sender, EventArgs e)
    {
        if (sign.Length == 1)//sign已存储运算符号
        {
            Count();        //调用自定义方法Count（）计算结果
            num1 = txtDisplay.Text;
            sign = "+";
        }
        else                //sign未存储运算符号
        {
            num1 = txtDisplay.Text;
            txtDisplay.Text = "";
            total = "";
            sign = "+";
        }
    }

    protected void btnSubtract_Click(object sender, EventArgs e)
    {
        if (sign.Length == 1)//sign已存储运算符号
        {
            Count();        //调用自定义方法Count（）计算结果
            num1 = txtDisplay.Text;
            sign = "-";
        }
        else                //sign未存储运算符号
        {
            num1 = txtDisplay.Text;
            txtDisplay.Text = "";
            total = "";
            sign = "-";
        }
    }

    protected void btnEqual_Click(object sender, EventArgs e)
    {
        if (sign.Length == 1)//sign已存储运算符号
        {
            Count();        //调用自定义方法Count（）计算结果
            num1 = txtDisplay.Text;
            sign = "=";
        }
        else                //sign未存储运算符号
        {
            num1 = txtDisplay.Text;
            txtDisplay.Text = "";
            total = "";
            sign = "=";
        }
    }
}